<?php

 /**
  * @package JooS
  * @subpackage Syntax_PHPackager
  */

  require_once "JooS/Syntax/Complex/Transition.php";

  class JooS_Syntax_PHPackager_DOM_Name extends JooS_Syntax_Complex_Transition {
    /**
     * @return string
     */
    public function compile() {
      $ret = parent::compile();
      if ($ret !== false) {
        $ret = strtolower($ret);
      }
      return $ret;
    }

    /**
     * @return JooS_Syntax_Complex_Concatenate
     */
    protected function createRule() {
      return $this->createSyntax("Complex_Concatenate", array(
        $this->createSyntax("Except", $this->createSyntax("Simple_None"), $this->createSyntax("Simple_Digit")), 
        $this->createSyntax("Complex_Repetition", $this->createSyntax("Complex_Choose", array(
          $this->createSyntax("Simple_Character"), 
          $this->createSyntax("Simple_Digit"), 
        )), 0, 1), 
        $this->createSyntax("Complex_Repetition", $this->createSyntax("Complex_Concatenate", array(
          $this->createSyntax("Simple_Symbol", "_"), 
          $this->createSyntax("Complex_Repetition", $this->createSyntax("Complex_Choose", array(
            $this->createSyntax("Simple_Character"), 
            $this->createSyntax("Simple_Digit"), 
          )), 0, 1), 
        )))
      ));
    }
  }
